import javax.swing.ImageIcon;
import javax.swing.JPanel;

import java.awt.*;

public class DrawPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void paintComponent(Graphics g) {
		g.setColor(Color.black);
		g.fillRect(0, 0, this.getWidth(), this.getHeight());
		
		int red = (int)(Math.random()*255);
		int green = (int)(Math.random()*255);
		int blue = (int)(Math.random()*255);
		
		int w = this.getWidth();
		int h = this.getHeight();
		
//		drawing solid color
//		Color randomColor = new Color(red, green, blue);
//		g.setColor(randomColor);
		
//		for using gradient fill, we must call functionality of Graphics2D (g is Graphics2D object, but it's inherited from Graphics) 
		Graphics2D g2d = (Graphics2D)g;
		GradientPaint gr = new GradientPaint(w/10, h/10, Color.green, w/3, w/3, Color.orange);
		g2d.setPaint(gr);
		g.fillOval(w/10, h/10, w/3, w/3);
		
//		drawing image
		Image i = new ImageIcon("res/team-arena.jpg").getImage();
		g.drawImage(i, w/3 + 3*w/10, h/10, w/3, w/3, this);
	}
}
